package view;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;

/**
 * The Class ArchiveReportGUI that extends AbstractGUI.
 * @author yudku
 */
public class ArchiveReportGUI  extends AbstractGUI
{
	
	/** The content pane. */
	private JPanel contentPane=null;
	
	/** The wrn message. */
	private JLabel wrnMessage=null;
	
	/** The label1_2. */
	private JLabel label1_2=null;
	
	/** The label2_2. */
	private JLabel label2_2=null;
	
	/** The label3_2. */
	private JLabel label3_2=null;
	
	/** The send. */
	private JButton send = null;
	
	/** The Photo det. */
	private JTextArea PhotoDet = null;
	
	/**
	 * Instantiates a new archive report gui.
	 */
	public ArchiveReportGUI()
	{
		super();
		contentPane=new JPanel();
	    contentPane.setBorder(new TitledBorder(null, "Archive Report", TitledBorder.LEADING, TitledBorder.TOP, null, null));	    
	    contentPane.setLayout(null);
	    contentPane.setOpaque(true);
	    contentPane.add(getBackButton());	
		contentPane.add(getWrnMessage());
		contentPane.add(getPhotoDet());
		  //Frame
	        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	        this.setTitle("Produce archive report window");
	        this.setContentPane(contentPane);  
	        

	        
	        JLabel label1_1 = new JLabel("Photos in Archive:");
	        label1_1.setBounds(42, 45, 190, 25);
	        contentPane.add(label1_1);
	        
	        JLabel label3_1 = new JLabel("Monthley Download rate:");
	        label3_1.setBounds(42, 95, 190, 25);
	        contentPane.add(label3_1);
	        
	        label1_2 = new JLabel(" --- ");
	        label1_2.setBounds(240, 45, 75, 25);
	        contentPane.add(label1_2);
	        
	        label3_2 = new JLabel(" ---");
	        label3_2.setBounds(240, 95, 75, 25);
	        contentPane.add(label3_2);
	        
	        send = new JButton("Send Report");
	        send.setBounds(86, 174, 120, 23);
	        contentPane.add(send);
	        
	        
		    this.setLocationRelativeTo(null); //This will center the JFrame in the middle of the screen
	        this.setLocationByPlatform(true);
	        this.setSize(800, 500);
	        this.setVisible( true ); // display frame
	        this.setContentPane(contentPane);
	
	}
	
	/**
	 * This method initializes Back Button.
	 *
	 * @return the back button
	 */
	private JButton getBackButton() {
		if (backButton == null) {
			backButton = new JButton();
			backButton.setBounds(new Rectangle(339, 400, 121, 23));
			backButton.setText("Back");
			
		}
		return backButton;
	}
	
	/**
	 * This method initializes text
	 *  Details Area.
	 *
	 * @return the photo det
	 */
	private JTextArea getPhotoDet() {
		if (PhotoDet == null) {
			PhotoDet = new JTextArea();
			PhotoDet.setBounds(new Rectangle(290, 50, 450, 300));
			PhotoDet.setBorder(BorderFactory.createLineBorder(Color.BLACK));
			
		}
		return PhotoDet;
	}
	 
	/**
	 * Sets the gen label.
	 *
	 * @param text the text
	 * @param label the label
	 */
	public void SetGenLabel(String text,JLabel label) {
		if (label != null) {

			label.setText(text);
		}
	}
	
	/**
	 * Gets the label1_2.
	 *
	 * @return the label1_2
	 */
	public JLabel getlabel1_2() {
		
		return label1_2;
	}
	
	/**
	 * Gets the label2_2.
	 *
	 * @return the label2_2
	 */
	public JLabel getlabel2_2() {
	
		return label2_2;
	}
	

	/**
	 * Gets the label3_2.
	 *
	 * @return the label3_2
	 */
	public JLabel getlabel3_2() {
		
		return label3_2;
	}
	
	/**
	 * Display wrn message.
	 *
	 * @param msg the msg
	 */
	public void displayWrnMessage(String msg){
		wrnMessage.setText(msg);
		wrnMessage.setVisible(true);
	}
	
	/**
	 * Gets the wrn message.
	 *
	 * @return the wrn message
	 */
	private JLabel getWrnMessage() {
		if (wrnMessage == null) {
			wrnMessage = new JLabel();
			wrnMessage.setForeground(Color.RED);
			wrnMessage.setBounds(70, 16, 320, 23);
			wrnMessage.setVisible(false);
		}
		return wrnMessage;
	}
	
	/**
	 * This set complaintField Area.
	 *
	 * @param msg the new photo det
	 */
	
	public void setPhotoDet(String msg){
		PhotoDet.setText(msg);
		PhotoDet.setVisible(true);
	}
	
	
	/**
	 * Adds the reply action listener.
	 *
	 * @param listener the listener
	 */
	public void addReplyActionListener(ActionListener listener){
		send.addActionListener(listener);
	}
	
	/**
	 * Click back button.
	 */
	public void clickBackButton()
	{
		this.getBackButton().doClick();
	}
	
}
